package cn.wgx.modules.sys.util;

import cn.wgx.modules.sys.entity.SysUser;


/**
 * 用户常量 类型（管理员=1; 平台教师=2; 学校教师=3; 学生=4; )
 */
public class UserTypeUtil {
    /**
     * 用户类型
     */
    // 管理员
    public static final Integer USER_TYPE_ADMIN = 1;
    // 平台教师
    public static final Integer USER_TYPE_TEACHER = 2;
    // 教师
    public static final Integer USER_TYPE_SCHOOL_TEACHER = 3;
    // 学生
    public static final Integer USER_TYPE_STUDENT = 4;
    // 演示,只能查看
    public static final Integer USER_TYPE_SCHOOL_TEST = 5;


    public static boolean isSchoolUser(){
        SysUser sysUser = UserUtil.getUser();
        return isStudent(sysUser) || isSchoolTeacher(sysUser) || isSchoolTest(sysUser);
    }

    public static boolean isStudent(){
        return isStudent(UserUtil.getUser());
    }

    public static boolean isAdmin(){
        return isAdmin(UserUtil.getUser());
    }

    public static boolean isSchoolTeacher(){
        return isSchoolTeacher(UserUtil.getUser());
    }

    public static boolean isTeacher(){
        return isTeacher(UserUtil.getUser());
    }




    public static boolean isStudent(Integer userId){
        return isStudent(UserUtil.getUserById(userId));
    }

    public static boolean isAdmin(Integer userId){
        return isAdmin(UserUtil.getUserById(userId));
    }

    public static boolean isSchoolTeacher(Integer userId){
        return isSchoolTeacher(UserUtil.getUserById(userId));
    }

    public static boolean isTeacher(Integer userId){
        return isTeacher(UserUtil.getUserById(userId));
    }




    public static boolean isSchoolTest(){
        return isSchoolTest(UserUtil.getUser());
    }

    public static boolean isSchoolTest(SysUser sysUser){
        return sysUser != null && USER_TYPE_SCHOOL_TEST.equals(sysUser.getType());
    }

    public static boolean isStudent(SysUser sysUser){
        return sysUser != null && USER_TYPE_STUDENT.equals(sysUser.getType());
    }

    public static boolean isAdmin(SysUser sysUser){
        return sysUser != null && USER_TYPE_ADMIN.equals(sysUser.getType());
    }

    public static boolean isSchoolTeacher(SysUser sysUser){
        return sysUser != null && USER_TYPE_SCHOOL_TEACHER.equals(sysUser.getType());
    }

    public static boolean isTeacher(SysUser sysUser){
        return sysUser != null && USER_TYPE_TEACHER.equals(sysUser.getType());
    }
}
